(define solus-memory)

memory <= (list s1 s2 s3 ...)
s <= (list state-name a1 a2 ...)
a <= (list action-name probability n-states)
n-states <= (list s1' s2' ...)
s1' <= (list state-name count)

(define (update-memory state actions memory) ())
(define (update-memory state action prob memory)
  (cond (null? memory) (update-memory state action prob (add-memory state action memory))
   (= (car (car memory)) state) ()
   
   )
)
(define (add-memory state action memory) ())

(define (select-highest-Q-action state memory) ())

(define (probability-of-reward state action memory) ())

(define (select-highest-T-state state action memory) ())

(define (next-state state action) (select-highest-T-state state action solus-memory))

(define (next-action state) (select-highest-Q-action state solus-memory))

(define (random state action) (probability-of-reward state action solus-memory))

(define (value state action n temp wtemp)
    (if (= n temp)
        (reward state action)
        (+ (reward state action) (* (/ 1 wtemp) (value (next-state state action) (next-action (next-state state action)) (+ n 1) temp wtemp)))
    )
)

(define (recalibrate-probabilities state action reward actions temp)
    (recal-iter (* (* (/ 1 temp) reward) action) actions action (- (length actions) 1)) ;R(s,a) = for s s(a)+=((1/n)*r)*a || for all s' s'(a)-= R(s,a)/A
)
(define (recal-iter amount actions exception n)
    (cond (null? actions) nil
        (eq? (car actions) exception) (cons (+ action amount) (recal-iter amount (cdr actions) exception n))
        else (cons (- action (/ amount n)) (recal-iter amount (cdr actions) exception n))
    )
)
(define (select-action state)
    (
        ;calculate the value of each available action
        ;give each action a chance proportional to the value
        ;randomly choose an action
    )
)
(define (Next-Action)
    (
        ; select-action
        ; add to memory
        ; return action
    )
)
(define (Apply-Result, state, reward, actions)
    (
        ; set actions
        ; add memory
        ; set state
        ; apply reward for recent memories ie recal-probabilities
    )
)
